﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using PlanningGIS.ArcGIS.Custom;
using PlanningGIS.Util;
using PlanningGIS.Win.Controls;

namespace PlanningGIS.MapSheet
{
    /// <summary>
    /// 图幅操作接口
    /// </summary>
    public interface IMapsheet
    {
        /// <summary>
        /// 图幅宽度
        /// </summary>
        double Width { get; set; }
        /// <summary>
        /// 图幅高度
        /// </summary>
        double Height { get; set; }
        /// <summary>
        /// 横向分幅的个数
        /// </summary>
        int ColLength { get; }
        /// <summary>
        /// 纵向分幅的个数
        /// </summary>
        int RowLength { get; }
        /// <summary>
        /// 获取横向图幅的总数
        /// </summary>
        int ColCount { get;  }
        /// <summary>
        /// 获取纵向图幅的总数
        /// </summary>
        int RowCount { get; }
        /// <summary>
        /// 单位值：1000米；100米；10米； 1米
        /// </summary>
        int UnitValue { get; set; }
        /// <summary>
        /// 获取或设置图幅大小字符串
        /// </summary>
        string SizeString { get; set; }

        /// <summary>
        /// 外扩距离，单位公里
        /// </summary>
        double OffsetLen { get; set; }

        /// <summary>
        /// 
        /// </summary>
        Progressor _Progressor { get; set; }

        ///// <summary>
        ///// 设置进度条总数委托
        ///// </summary>
        //SetProgressTotalEvent SetProgressTotal { get; set; }
        ///// <summary>
        ///// 设置进度条当前的值
        ///// </summary>
        //SetProgressValueEvent SetProgressValue { get; set; }

        /// <summary>
        /// 根据空间对象创建图幅图层
        /// </summary>
        /// <param name="geometry">要创建图幅的空间范围：矩形或多边形</param>
        /// <param name="sheetFeatureClass">要创建到的图幅图层</param>
        /// <param name="fieldSheetName">图幅名称字段</param>
        /// <param name="scale">要创建图幅的比例尺</param>
        /// <param name="removespace">是否移除与空间对象不想交的空白图幅。默认为false：不移除</param>
        /// <returns>true创建成功；false创建失败</returns>
        bool CreateMapSheet(IGeometry geometry, IFeatureClass sheetFeatureClass, string fieldSheetName, SheetScale scale, bool removespace = false);

        /// <summary>
        /// 根据图层（如行政区化）创建图幅图层
        /// </summary>
        /// <param name="fullFeatureClass">要创建图幅的图层范围：如行政区化</param>
        /// <param name="sheetFeatureClass">要创建到的图幅图层</param>
        /// <param name="fieldSheetName">图幅名称字段</param>
        /// <param name="scale">要创建图幅的比例尺</param>
        /// <param name="removespace">是否移除与空间对象不想交的空白图幅。默认为false：不移除</param>
        /// <returns>true创建成功；false创建失败</returns>
        bool CreateMapSheet(IFeatureClass fullFeatureClass, IFeatureClass sheetFeatureClass, string fieldSheetName, SheetScale scale, bool removespace = false);

        /// <summary>
        /// 根据图幅号获取图幅对象
        /// </summary>
        /// <param name="sheetcode">带有比例尺标识的图幅号</param>
        /// <returns></returns>
        Mapsheet GetMapSheet(string sheetcode);

        /// <summary>
        /// 根据图幅号获取图幅对象。以图号为准
        /// </summary>
        /// <param name="sheetcode">不带有比例尺标识的图幅号</param>
        /// <param name="scale">对应的比例尺</param>
        /// <returns></returns>
        Mapsheet GetMapSheet(string sheetcode, SheetScale scale);

        /// <summary>
        /// 根据坐标点获取图幅对象
        /// </summary>
        /// <param name="x">指定的坐标点的X坐标（经度）</param>
        /// <param name="y">指定的坐标点的Y坐标（纬度）</param>
        /// <param name="scale">对应的比例尺</param>
        /// <returns></returns>
        Mapsheet GetMapSheet(double x, double y, SheetScale scale);

        /// <summary>
        /// 获取坐标点在指定比例尺的图幅号
        /// </summary>
        /// <param name="x">指定的坐标点的X坐标（经度）</param>
        /// <param name="y">指定的坐标点的Y坐标（纬度）</param>
        /// <param name="scale">对应的比例尺</param>
        /// <returns></returns>
        string GetSheetCode(double x, double y, SheetScale scale);

        /// <summary>
        /// 根据图幅号获取西南角（左下角）点的坐标
        /// </summary>
        /// <param name="sheetcode">带有比例尺标识的图幅号</param>
        /// <returns></returns>
        IPoint GetWestSouthPoint(string sheetcode);

        /// <summary>
        /// 根据图幅号获取西南角（左下角）点的坐标。以图号为准
        /// </summary>
        /// <param name="sheetcode">不带有比例尺标识的图幅号</param>
        /// <param name="scale">对应的比例尺</param>
        /// <returns></returns>
        IPoint GetWestSouthPoint(string sheetcode, SheetScale scale);

        /// <summary>
        /// 根据图号获取其四周8个方向的图幅与自身所在的图幅，按从上到下，从左到右排列
        /// </summary>
        /// <param name="sheetcode">图号</param>
        /// <returns></returns>
        List<Mapsheet> GetMapSheets(string sheetcode);

        /// <summary>
        /// 根据图号获取其四周8个方向的图幅与自身所在的图幅，按从上到下，从左到右排列。以图号为准
        /// </summary>
        /// <param name="sheetcode">图号</param>
        /// <param name="scale">比例尺</param>
        /// <returns></returns>
        List<Mapsheet> GetMapSheets(string sheetcode, SheetScale scale);

        /// <summary>
        /// 根据坐标点获取其四周8个方向的图幅与自身所在的图幅，按从上到下，从左到右排列
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="scale">比例尺</param>
        /// <returns></returns>
        List<Mapsheet> GetMapSheets(double x, double y, SheetScale scale);

        /// <summary>
        /// 获取空间对象所在的图幅集合对象
        /// </summary>
        /// <param name="geometry">空间范围</param>
        /// <param name="scale">对应的比例尺</param>
        /// <param name="removespace">是否移除与空间对象不想交的空白图幅。默认为true：移除</param>
        /// <returns></returns>
        List<Mapsheet> GetMapSheets(IGeometry geometry, SheetScale scale, bool removespace = true);

        /// <summary>
        /// 获取空间对象所在的图幅集合对象
        /// </summary>
        /// <param name="geometry">空间范围</param>
        /// <param name="scale">对应的比例尺</param>
        /// <param name="removespace">是否移除与空间对象不想交的空白图幅。默认为true：移除</param>
        /// <returns></returns>
        List<Mapsheet> GetMapSheets(List<IGeometry> geometry, SheetScale scale, bool removespace = true);

        /// <summary>
        /// 检查图号是否正确，且与比例尺是否一致
        /// </summary>
        /// <param name="sheetcode"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        bool CheckCodeAndScale(string sheetcode, SheetScale scale);

        /// <summary>
        /// 是否为标准的图幅号
        /// </summary>
        /// <param name="sheetcode"></param>
        /// <returns></returns>
        bool IsGBCode(string sheetcode);

    }
}
